package com.reder.practice.common.util;

import com.reder.practice.common.dto.ServerResponse;
import com.reder.practice.common.enums.Statable;
import com.reder.practice.common.enums.state.CommonState;

/**
 * 判断sql结果工具类
 *
 * @author Red
 * <p>Email: 1318944013@qq.com</p>
 * <p>created by 2019/09/23 11:31</p>
 */
public class SqlResultUtil {

    /**
     *  判断sql执行结果，并且返回对应的ServerResponse
     *
     * @param result sql执行结果
     * @param statable 返回的状态
     * @return ServerResponse
     */
    public static ServerResponse checkSqlResult(int result, Statable statable) {
        if (result <= 0) {
            return ServerResponse.response(statable);
        }
        return ServerResponse.response(CommonState.SUCCESS);
    }
}
